package com.administrator.cloudapplication.activitys;

import android.webkit.WebSettings;
import android.webkit.WebView;

import com.administrator.cloudapplication.R;
import com.administrator.cloudapplication.base.BaseActivity;
import com.administrator.cloudapplication.constant.Urls;

/**
 * 本页面只有一个WebView，所以所有的webview页面都可以复用这个页面。
 * Created by 祁晓峰 on 2017/4/20.
 */

public class MedioDetailActivity extends BaseActivity {
    private WebView mWebView;
    private String url;
    private String vid, title_name;//WebView的网址拼接必须要一个id。
    int type;//传递过来一个变量，用来写入不同的网址来加载WebView。

    @Override
    protected void initView() {
        setContentView(R.layout.activity_mediadedetail);
        mWebView = (WebView) findViewById(R.id.wv_medio);
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setSupportZoom(true);
        webSettings.setDisplayZoomControls(true);
        webSettings.setJavaScriptEnabled(true);
    }

    @Override
    protected void initData() {
        vid = getIntent().getStringExtra("vid");
        title_name = getIntent().getStringExtra("title_name");
        type = getIntent().getIntExtra("type", 0);
        switch (type) {
            case 0:
                url = Urls.BASE_URL2 + Urls.VIDEO_DETAIL + vid;
                break;
            case 1:
                url = Urls.BASE_URL2 + Urls.AUDIO_DETAIL + vid;
                break;
            case 2:
                url = Urls.BASE_URL2 + Urls.BOOK_READ + vid;
                break;
        }

        mWebView.loadUrl(url);
       /* tvTitle.setText(title_name);*/
    }

    @Override
    protected void onLeftClick() {
        finish();
    }

    @Override
    protected void onRightClick() {

    }
}
